<html>
<head><meta charset="utf-8"><title>bool == _Bool · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html">bool == _Bool</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="151115441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115441">(Dec 07 2018 at 14:34)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> ehmm I actually argued that we should remain compatible with C ? I opened that issue because of due process, because most of you actually agreed that supporting platforms that are "weird" was not worth doing</p>



<a name="151115470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115470">(Dec 07 2018 at 14:35)</a>:</h4>
<p>saying <code>bool == _Bool</code> is incompatible with <code>CHAR_BITS == 8</code> and pretty much anything else with respect to C FFI AFAICT</p>



<a name="151115850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115850">(Dec 07 2018 at 14:40)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I don't care the slightest what we say about the size of <code>bool</code></p>



<a name="151115864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115864">(Dec 07 2018 at 14:41)</a>:</h4>
<blockquote>
<p>saying <code>bool == _Bool</code> is incompatible with <code>CHAR_BITS == 8</code> and pretty much anything else with respect to C FFI AFAICT</p>
</blockquote>
<p>no it isn't?</p>



<a name="151115882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115882">(Dec 07 2018 at 14:41)</a>:</h4>
<p><code>CHAR_BITS == 8</code> just means "we dont care about platforms where that condition does not hold"</p>



<a name="151115884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115884">(Dec 07 2018 at 14:41)</a>:</h4>
<p>If <code>CHAR_BITS != 8</code>, then <code>bool != _Bool</code></p>



<a name="151115891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115891">(Dec 07 2018 at 14:41)</a>:</h4>
<p>no</p>



<a name="151115897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115897">(Dec 07 2018 at 14:41)</a>:</h4>
<p>it just makes such platforms out-of-scope</p>



<a name="151115908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151115908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151115908">(Dec 07 2018 at 14:41)</a>:</h4>
<p><code>bool == _Bool</code> means "on all platforms we support, this holds"</p>



<a name="151116040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116040">(Dec 07 2018 at 14:43)</a>:</h4>
<p>or, put differently: <code>CHAR_BITS == 8</code> means that we pretend that platforms where <code>CHAR_BITS != 8</code> do not exist. If they happen to exist (and I know they do but that's not the point), we just do not care about them, do not want to support them.</p>



<a name="151116047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116047">(Dec 07 2018 at 14:43)</a>:</h4>
<p>I do not see how that in any way implies anything about <code>bool</code></p>



<a name="151116194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116194">(Dec 07 2018 at 14:45)</a>:</h4>
<p><code>bool == _Bool</code> means on all platform we will ever support, this must hold, not just "hold on C FFI"</p>



<a name="151116247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116247">(Dec 07 2018 at 14:46)</a>:</h4>
<p>yes?</p>



<a name="151116256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116256">(Dec 07 2018 at 14:46)</a>:</h4>
<p>this means that if the requirement <code>bool == _Bool</code> cannot be satisfied, then that platform cannot be targetted at all AFAICT</p>



<a name="151116260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116260">(Dec 07 2018 at 14:46)</a>:</h4>
<p>and all platforms we ever support will have <code>CHAR_BITS == 8</code></p>



<a name="151116274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116274">(Dec 07 2018 at 14:46)</a>:</h4>
<p>that's what "assuming <code>CHAR_BITS == 8</code>" means</p>



<a name="151116297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116297">(Dec 07 2018 at 14:47)</a>:</h4>
<p>not really</p>



<a name="151116316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116316">(Dec 07 2018 at 14:47)</a>:</h4>
<p>I dont know what you mean by "hold on C FFI".</p>



<a name="151116347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116347">(Dec 07 2018 at 14:47)</a>:</h4>
<blockquote>
<p>not really</p>
</blockquote>
<p>what else could it mean? we make an assumption, so platforms that dont satisfy that assumption are not supported.</p>



<a name="151116353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116353">(Dec 07 2018 at 14:47)</a>:</h4>
<p>the difference is that <code>CHAR_BITS == 8</code>is required to, e.g., use a bool properly in C FFI, if C has a <code>CHAR_BITS == 16</code>, then you could pass an <code>u16</code> to communicate a "bool" with C</p>



<a name="151116463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116463">(Dec 07 2018 at 14:48)</a>:</h4>
<p>if C has <code>CHAR_BITS == 16</code> Rust does not run on that platform.</p>



<a name="151116487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116487">(Dec 07 2018 at 14:49)</a>:</h4>
<p>why not ?</p>



<a name="151116500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116500">(Dec 07 2018 at 14:49)</a>:</h4>
<p>you said yourself we assume <code>CHAR_BITS == 8</code></p>



<a name="151116504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116504">(Dec 07 2018 at 14:49)</a>:</h4>
<p>of course it does, as long as you don't use C FFI, it doesn't really matter</p>



<a name="151116506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116506">(Dec 07 2018 at 14:49)</a>:</h4>
<p>you are really confusing me^^</p>



<a name="151116527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116527">(Dec 07 2018 at 14:49)</a>:</h4>
<p>we expect <code>CHAR_BITS == 8</code> to be able to do C FFI with some Rust types with a C ABI</p>



<a name="151116549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116549">(Dec 07 2018 at 14:49)</a>:</h4>
<p>oh, you are saying <code>CHAR_BITS == 8</code> is just a requirement to do C FFI? not a requirement to run at all on that platform?</p>



<a name="151116597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116597">(Dec 07 2018 at 14:50)</a>:</h4>
<p>that's not at all how I read these things</p>



<a name="151116616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116616">(Dec 07 2018 at 14:50)</a>:</h4>
<p>iff <code>CHAR_BITS != 8</code>, then we can't maybe use <code>bool</code> on C FFI, but we could use something else</p>



<a name="151116634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116634">(Dec 07 2018 at 14:50)</a>:</h4>
<p>even assuming that is the intended interpretation (not sure if it is, doesnt sound unreasonable): this still means that if <code>CHAR_BITS != 8</code>, you cannot do FFI, so <code>_Bool</code> literally doesnt matter</p>



<a name="151116669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116669">(Dec 07 2018 at 14:51)</a>:</h4>
<p>you can do FFI, but not necessarily with the same types that you use in a platform where <code>CHAR_BITS == 8</code>.</p>



<a name="151116670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116670">(Dec 07 2018 at 14:51)</a>:</h4>
<p>talking about C types like <code>_Bool</code> only makes sense in the context of FFI</p>



<a name="151116745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116745">(Dec 07 2018 at 14:52)</a>:</h4>
<blockquote>
<p>you can do FFI, but not necessarily with the same types that you use in a platform where <code>CHAR_BITS == 8</code>.</p>
</blockquote>
<p>now you are <em>really</em> stretching the assumption here. I think that is an unreasonable interpretation.</p>



<a name="151116755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116755">(Dec 07 2018 at 14:52)</a>:</h4>
<p>the difference is that <code>bool == _Bool</code> impacts all Rust code using <code>bool</code>, not just the tiny portion of code trying to communicate with C's <code>_Bool</code> via C FFI</p>



<a name="151116768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116768">(Dec 07 2018 at 14:52)</a>:</h4>
<p>we said <code>CHAR_BITS == 8</code> because other platforms are so niche we dont care about them</p>



<a name="151116786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116786">(Dec 07 2018 at 14:52)</a>:</h4>
<p>because we <em>dont want to have these silly discussions</em></p>



<a name="151116816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116816">(Dec 07 2018 at 14:53)</a>:</h4>
<p>now you are reinterpreting that statement in a way such that suddenly platforms violating our assumtpions can matter again. that's not what these assumptions are for.</p>



<a name="151116840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116840">(Dec 07 2018 at 14:53)</a>:</h4>
<p><span class="user-mention" data-user-id="133214">@briansmith</span> mentioned that they rely on doing C FFI with those platforms</p>



<a name="151116857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116857">(Dec 07 2018 at 14:53)</a>:</h4>
<p>well, they should talk with <span class="user-mention" data-user-id="137587">@Gankro</span> then who declared such platforms out-of-scope</p>



<a name="151116911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116911">(Dec 07 2018 at 14:54)</a>:</h4>
<p><span class="user-mention" data-user-id="137587">@Gankro</span> also declared platforms with <code>bool == _Bool</code> out of scope</p>



<a name="151116932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116932">(Dec 07 2018 at 14:54)</a>:</h4>
<p>you mean <code>!=</code>?</p>



<a name="151116942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116942">(Dec 07 2018 at 14:54)</a>:</h4>
<p>when they stated that we don't care about bool with size != 1</p>



<a name="151116945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116945">(Dec 07 2018 at 14:54)</a>:</h4>
<p>well that statement is tautological</p>



<a name="151116955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116955">(Dec 07 2018 at 14:54)</a>:</h4>
<p>we defined <code>bool == _Bool</code> so it holds for all supported platforms^^</p>



<a name="151116989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116989">(Dec 07 2018 at 14:55)</a>:</h4>
<p>what platforms is brian doing this on?</p>



<a name="151116993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151116993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151116993">(Dec 07 2018 at 14:55)</a>:</h4>
<p>so this is really a discussion about some people anyway wanting to support such obscure platforms. okay. but then let's frame it as such, not pretend that this is about <code>bool</code> which it isn't.</p>



<a name="151117061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117061">(Dec 07 2018 at 14:56)</a>:</h4>
<p>? <span class="user-mention" data-user-id="120791">@RalfJ</span> I argued that <code>bool</code> with size == 1 is the only thing worth supporting in Rust</p>



<a name="151117100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117100">(Dec 07 2018 at 14:56)</a>:</h4>
<p>that does not imply that doing C FFI with platforms where the machine code on the other side expects something different has to be impossible</p>



<a name="151117108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117108">(Dec 07 2018 at 14:56)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> you argued that <code>bool == _Bool</code> is somehow incompatible with <code>CHAR_SIZE == 8</code>. I think that's logically wrong. that's why I commented.</p>



<a name="151117128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117128">(Dec 07 2018 at 14:57)</a>:</h4>
<p>it is, because <code>_Bool</code> is defined for all <code>CHAR_SIZE</code>s</p>



<a name="151117235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117235">(Dec 07 2018 at 14:58)</a>:</h4>
<p>it is not, because we cant do no FFI on platforms on which we dont support FFI, and hence <code>_Bool</code> just doesnt matter there. if your goal is to add <code>sizeof(_Bool) == 1</code> to our platforms requirements, that's cool, but please say so :)</p>



<a name="151117278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117278">(Dec 07 2018 at 14:58)</a>:</h4>
<p>no, i am not proposing that, i proposed that <code>bool</code> has size of 1, <code>_Bool</code> can have whatever size it wants, doesn't really matter</p>



<a name="151117317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117317">(Dec 07 2018 at 14:59)</a>:</h4>
<p>if <code>_Bool</code> has size 2, and our <code>bool</code> has size 1, then if you only write Rust code, or C code, and they don't interact, then both programs are correct and work and are portable</p>



<a name="151117397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117397">(Dec 07 2018 at 15:00)</a>:</h4>
<p>the problem is if you try to use <code>bool</code> in C FFI, and the other side (C, assembly, or some other code) expects a type with size 2, and you provide a type with size 1</p>



<a name="151117412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117412">(Dec 07 2018 at 15:00)</a>:</h4>
<p>then that's a problem, but if on the Rust side you pass an <code>u16</code>, and then cast it to a <code>bool</code>, then that's ok</p>



<a name="151117422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117422">(Dec 07 2018 at 15:00)</a>:</h4>
<p>I am not willing to follow your strange interpretation of "no FFI support for <code>CHAR_SIZE != 8</code>" meaning "you can still do FFI but have to be a bit more careful around integer types". I think "no FFI support for <code>CHAR_SIZE != 8</code>" means "<strong>no FFI support</strong> for <code>CHAR_SIZE != 8</code>" and if you insist on doing FFI anyway, literally anything might happen and your use case is just too niche for us to even consider it in these discussions.</p>



<a name="151117477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117477">(Dec 07 2018 at 15:01)</a>:</h4>
<p>so for you, if C breaks any of Rust requirements, no C FFI is possible at all</p>



<a name="151117484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117484">(Dec 07 2018 at 15:01)</a>:</h4>
<p>yes</p>



<a name="151117527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117527">(Dec 07 2018 at 15:02)</a>:</h4>
<p>that's the point of making such assumptions</p>



<a name="151117540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117540">(Dec 07 2018 at 15:02)</a>:</h4>
<p>so that we dont have to spend our afternoons discussing arcane platforms^^</p>



<a name="151117551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117551">(Dec 07 2018 at 15:02)</a>:</h4>
<p>so I am 100% against that</p>



<a name="151117577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117577">(Dec 07 2018 at 15:02)</a>:</h4>
<p>the assumptions aren't a zero sum game</p>



<a name="151117611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117611">(Dec 07 2018 at 15:03)</a>:</h4>
<p>so you want some kind of "degraded FFI" to still be possible for platforms violating platform assumptions?</p>



<a name="151117623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117623">(Dec 07 2018 at 15:03)</a>:</h4>
<p>the thing is, we use C FFI for interacting with everything that is not rust</p>



<a name="151117700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117700">(Dec 07 2018 at 15:04)</a>:</h4>
<p>if I have a 99.999999% Rust program, and need to link an assembly blob and call it via C FFI, i am in control of everything, and don't really care what the size of <code>_Bool</code> in the platform is, only what Rust actually expects</p>



<a name="151117709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117709">(Dec 07 2018 at 15:04)</a>:</h4>
<p>I can see why you would want that, but I don't think that "we only support C with <code>CHAR_SIZE == 8</code>" leaves room for that interpretaion. so I think what you are proposing is to go back even further and say that we do want to support some things on <code>CHAR_SIZE != 8</code>. you have to take it up with <span class="user-mention" data-user-id="137587">@Gankro</span> from there, I don't really have a stanza here ;)</p>



<a name="151117722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117722">(Dec 07 2018 at 15:05)</a>:</h4>
<p>so forbidding all C FFI is just too much</p>



<a name="151117764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117764">(Dec 07 2018 at 15:05)</a>:</h4>
<p>i can live with it, but I just want some concrete platforms we care about enabling with this</p>



<a name="151117769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117769">(Dec 07 2018 at 15:05)</a>:</h4>
<p>I think that if <code>bool != _Bool</code> then using <code>bool</code> on C FFI should just warn that <code>bool</code> is an improper C type</p>



<a name="151117855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117855">(Dec 07 2018 at 15:06)</a>:</h4>
<p>we can then specify <code>bool</code> as it makes sense for Rust, and it just so happens that it makes sense for all C platforms that we support today (and who knows, maybe ever)</p>



<a name="151117886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117886">(Dec 07 2018 at 15:07)</a>:</h4>
<p>if a C platform does not support it how we need it, then people will need to figure out how to interface with that platform via C FFI, but that should not require making <code>bool</code>s weird for all Rust code</p>



<a name="151117954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151117954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151117954">(Dec 07 2018 at 15:08)</a>:</h4>
<p>it should not make interfacing with the platform impossible either</p>



<a name="151118236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118236">(Dec 07 2018 at 15:13)</a>:</h4>
<p>the goal of that decision (<code>bool</code> == <code>_Bool</code>) was to avoid people using a <code>c_bool</code> type for FFI. your proposal is in direct contradiction to that.</p>



<a name="151118287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118287">(Dec 07 2018 at 15:13)</a>:</h4>
<p>And the rationale of the decision stated that another goal was for people to use <code>bool</code> in Rust instead of <code>u8</code> to get a "1 byte wide" bool, but that goal was not met with the decision</p>



<a name="151118378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118378">(Dec 07 2018 at 15:14)</a>:</h4>
<p>I think it is fairly clear from the text that the teams were aware that this could mean that bool has size != 1 on some platforms</p>



<a name="151118425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118425">(Dec 07 2018 at 15:15)</a>:</h4>
<p>boats explicitly wrote</p>
<blockquote>
<p>We document this, and also document that on every platform we currently support, this means that the size of bool is 1.</p>
</blockquote>



<a name="151118426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118426">(Dec 07 2018 at 15:15)</a>:</h4>
<p>so I dont know why you claim they wanted <code>bool</code> to have size 1 on all platforms</p>



<a name="151118434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118434">(Dec 07 2018 at 15:15)</a>:</h4>
<p>Yet <span class="user-mention" data-user-id="137587">@Gankro</span> and others have argued since that guaranteeing that bool has a size of 1 is worth it because supporting those platforms isn't worth it</p>



<a name="151118487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118487">(Dec 07 2018 at 15:16)</a>:</h4>
<p>you seem to be arguing that supporting those platforms isn't worth it yourself</p>



<a name="151118499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118499">(Dec 07 2018 at 15:16)</a>:</h4>
<p>nono dont shift arguments</p>



<a name="151118508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118508">(Dec 07 2018 at 15:16)</a>:</h4>
<p>first, the team decision</p>



<a name="151118543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118543">(Dec 07 2018 at 15:17)</a>:</h4>
<p>as i mentioned, is unclear, the PR that implemented the decision just specified that <code>bool</code> has size of <code>1</code>, but I suppose that's what they meant with only documenting it for the platforms that we support now</p>



<a name="151118625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118625">(Dec 07 2018 at 15:18)</a>:</h4>
<p><span class="user-mention" data-user-id="137587">@Gankro</span> 's Layout and ABI post sets it as size of 1, not as <code>_Bool</code></p>



<a name="151118646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118646">(Dec 07 2018 at 15:18)</a>:</h4>
<p>do you argee that they were aware that this could mean bool has size != 1 on some platforms?</p>



<a name="151118683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118683">(Dec 07 2018 at 15:19)</a>:</h4>
<p>they were aware, and they were aware that that could be a problem</p>



<a name="151118692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118692">(Dec 07 2018 at 15:19)</a>:</h4>
<p>but all options have problems</p>



<a name="151118697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118697">(Dec 07 2018 at 15:19)</a>:</h4>
<p>and they decided anyway. so let's document that.</p>



<a name="151118775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118775">(Dec 07 2018 at 15:20)</a>:</h4>
<p>i was tasked in the last meeting to open an issue an involve those from those dicussions to 1) clarify more precisely what they meant, and 2) discuss new information</p>



<a name="151118803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118803">(Dec 07 2018 at 15:20)</a>:</h4>
<p>and then you and <span class="user-mention" data-user-id="137587">@Gankro</span> and <span class="user-mention" data-user-id="133214">@briansmith</span> can discuss which assumptions we make about C platforms, and which consequences that has, and maybe you want to write an RFC to change the <code>bool</code> decision. but <span class="user-mention" data-user-id="137587">@Gankro</span>'s proposed requirements are not in contradiction with the team decision, nor is any subset of them. you just dont like the consequences of that decision combined with some undecided assumptions.</p>



<a name="151118808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118808">(Dec 07 2018 at 15:20)</a>:</h4>
<p>that <span class="user-mention" data-user-id="126854">@avadacatavra</span> post should document <code>bool == _Bool</code> for the time being until that was resolved was also decided in the last meeting</p>



<a name="151118869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118869">(Dec 07 2018 at 15:21)</a>:</h4>
<p>i don't recall saying anything about an RFC, somebody argued that when that decision was made not all options might have been considered</p>



<a name="151118951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118951">(Dec 07 2018 at 15:22)</a>:</h4>
<p>e.g. the possibility of diagnosing improper usage of <code>bool</code> on C FFI on the platforms in which its usage is not proper</p>



<a name="151118952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118952">(Dec 07 2018 at 15:22)</a>:</h4>
<p>I think you need an RFC to change that decision</p>



<a name="151118990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151118990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151118990">(Dec 07 2018 at 15:23)</a>:</h4>
<p>maybe? its unclear whether its even worth changing, which is why the issue was opened</p>



<a name="151119093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119093">(Dec 07 2018 at 15:25)</a>:</h4>
<p>even if it would be worth changing, none of those decision went through the RFC process, so a mini-FCP might be enough</p>



<a name="151119103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119103">(Dec 07 2018 at 15:25)</a>:</h4>
<p>but anyway, I am going to do something else now because I learned what I wanted to learn from this discussion^^ I hope maybe I was able to at least convey why the way you are framing things is terribly confusing.</p>
<p>If I could make a suggestion: start by writing down the high-level problem statement ("which kind of platforms do we want to support FFI on, and what consequences does it have on the rest of the language if we support certain arcane things, and how badly do things degrade on non-supported platforms"). There's an entire matrix of possible decisions and consequences here and only in a few cells of this matrix does the <code>bool == _Bool</code> decision become a problem. Starting with some nitty-gritty detail that is a consequence of several not-yet-made-decisions is really hard to follow.</p>



<a name="151119212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119212">(Dec 07 2018 at 15:27)</a>:</h4>
<p>That's what the first post of the issue attempted to do</p>



<a name="151119312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119312">(Dec 07 2018 at 15:29)</a>:</h4>
<p>the title says it's all about bool, but I think if I understood one thing here then its that that's not the case</p>



<a name="151119366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119366">(Dec 07 2018 at 15:30)</a>:</h4>
<p>If we just say <code>bool == _Bool</code> then unsafe code cannot rely on the size of <code>bool</code>, the bit patterns of true and false, etc.</p>



<a name="151119380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119380">(Dec 07 2018 at 15:30)</a>:</h4>
<p>transmute might comply loudly about this, but type punning through an union won't</p>



<a name="151119434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119434">(Dec 07 2018 at 15:31)</a>:</h4>
<p>guaranteeing anything more at all about <code>bool</code> is incompatible with the T-lang and T-compiler decision that <code>bool == _Bool</code></p>



<a name="151119462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119462">(Dec 07 2018 at 15:31)</a>:</h4>
<p>I agree with that observation</p>



<a name="151119528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119528">(Dec 07 2018 at 15:32)</a>:</h4>
<p>but that is a discussion that's mostly independent of C platform requirements and FFI</p>



<a name="151119555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119555">(Dec 07 2018 at 15:33)</a>:</h4>
<p>there is an intersection at "we could just require the C platform to be like most of them are"</p>



<a name="151119563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119563">(Dec 07 2018 at 15:33)</a>:</h4>
<p>if C20 and C++20 goes as expected, then the bit patterns of bool become fixed, as long as we require C20 compatibility, which the T-compiler and T-lang did not do, otherwise they still are unspecified</p>



<a name="151119583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119583">(Dec 07 2018 at 15:33)</a>:</h4>
<p>the size of <code>bool</code> would still remain unspecified</p>



<a name="151119593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119593">(Dec 07 2018 at 15:33)</a>:</h4>
<p>but both discussions (the bool discussion and the C platform requirements discussion) go way beyond that, and your issue is mixing all of these three things up in a messy way I'm afraid</p>



<a name="151119847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119847">(Dec 07 2018 at 15:37)</a>:</h4>
<p>I mean the issue has two questions at the end that would be nice to resolve: what C standard does <code>_Bool</code> need to abide, if any ? (If we don't specify any, unsafe Rust can at most assume C99) If we specify one, then that fixes some things that unsafe Rust is allowed to assume about bool</p>



<a name="151119927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119927">(Dec 07 2018 at 15:38)</a>:</h4>
<p>And the second question is: do we want / is it worth it to require <code>bool</code> to have a size and alignment of 1. That would be something that unsafe Rust would be able to assume that it cannot assume right now.</p>



<a name="151119974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151119974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151119974">(Dec 07 2018 at 15:39)</a>:</h4>
<p>Even if UCG just says "<code>bool == _Bool</code>" it would be nicer if it could say <code>_Bool</code> according to which C standard.</p>



<a name="151120338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151120338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151120338">(Dec 07 2018 at 15:44)</a>:</h4>
<p>I don't have the time to be dragged deep into this discussion but I want to point out that besides "C platforms with weird bools" being mostly or entirely hypothetical, code (including unsafe code) <em>can</em> assume things that are not technically true about every platform Rust might ever target (such as maybe bool being a byte), if it only works on platforms where that is true. Bools are not the first and by far not the most realistic example where one might want to do that. "Complete portability" including to such weirdo platforms is neither achievable nor desirable for 99.99% of software anyway, <a href="https://github.com/rust-rfcs/unsafe-code-guidelines/issues/9#issuecomment-419892030" target="_blank" title="https://github.com/rust-rfcs/unsafe-code-guidelines/issues/9#issuecomment-419892030">as I have argued previously</a>.</p>



<a name="151123218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123218">(Dec 07 2018 at 16:26)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> the question is whether we should guarantee that so that most people don't have to assume this "at their own risk"</p>



<a name="151123255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123255">(Dec 07 2018 at 16:26)</a>:</h4>
<p>people targetting platforms with weird <code>bool</code>s are going to have bigger problems than "I can't use <code>bool</code> on C FFI and <code>c_bool</code> is not a thing".</p>



<a name="151123289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123289">(Dec 07 2018 at 16:27)</a>:</h4>
<p>The ship for such a simple question has sailed. Now it's knee deep in "wtf even is C in practice" and other annoying enigmas.</p>



<a name="151123311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123311">(Dec 07 2018 at 16:27)</a>:</h4>
<p>we should not make targetting those platforms "impossible", but I don't think it is worth it to leave all properties of <code>bool</code> unspecified just to make something hard only slightly less hard</p>



<a name="151123373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123373">(Dec 07 2018 at 16:28)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> what do you mean with "has sailed" ?</p>



<a name="151123436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123436">(Dec 07 2018 at 16:30)</a>:</h4>
<p>We're now in the situation that we have a settled policy/framing that covers all the remotely normal platforms. Even raising the possibility of re-litigating bool layout necessarily gets deep into hypothetical or long-dead platforms and the extremely hard and annoying topic of "platforms with no/outdated/non-conforming C platforms".</p>



<a name="151123494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123494">(Dec 07 2018 at 16:30)</a>:</h4>
<p>Which is also why this is such an intensely frustrating discussion.</p>



<a name="151123593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123593">(Dec 07 2018 at 16:31)</a>:</h4>
<p>it's not "at their own risk". it's unsafe code being less portable than general Rust code. That's okay, they should just document that (and ideally make sure that their code fails to compile on unsupported platforms)</p>



<a name="151123663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123663">(Dec 07 2018 at 16:32)</a>:</h4>
<p>they might need to test for bitpatterns of true and false and many other annoying things</p>



<a name="151123675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123675">(Dec 07 2018 at 16:32)</a>:</h4>
<p>updating our notion of <code>_Bool</code> together with C/C++ seems perfectly reasonable, I dont think anyone would disagree with that</p>



<a name="151123680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123680">(Dec 07 2018 at 16:32)</a>:</h4>
<p>so the only remaining question is the size</p>



<a name="151123761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123761">(Dec 07 2018 at 16:33)</a>:</h4>
<p>all it takes is for someone to write a crate that performs bool &lt;-&gt; u8 conversion (checked and unchecked) and makes sure it fails to compile if the types dont match. then tell everyone else to use that crate <em>if</em> they really need to inspect bool bit-wise. no magic needed.</p>



<a name="151123773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123773">(Dec 07 2018 at 16:33)</a>:</h4>
<p>What value does leaving the size unspecified add ?</p>



<a name="151123824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123824">(Dec 07 2018 at 16:34)</a>:</h4>
<p>supporting FFI on platforms where the size is different</p>



<a name="151123826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123826">(Dec 07 2018 at 16:34)</a>:</h4>
<p>I dont know if we should care</p>



<a name="151123842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123842">(Dec 07 2018 at 16:34)</a>:</h4>
<p>just saying both options are reasonable</p>



<a name="151123851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123851">(Dec 07 2018 at 16:34)</a>:</h4>
<p>also, technical conformance with C/C++, which eliminates one reason why people might think they need a c_bool</p>



<a name="151123895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123895">(Dec 07 2018 at 16:35)</a>:</h4>
<p>(at least "more" conformance, depending on the version of C and C++ in question)</p>



<a name="151123904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123904">(Dec 07 2018 at 16:35)</a>:</h4>
<p>I don't know what real value that adds. Chances are, lot of Rust code won't be usable on those platforms either =/</p>



<a name="151123923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123923">(Dec 07 2018 at 16:35)</a>:</h4>
<p>Would definitely be one thing less to deal with when porting existing code to those platforms</p>



<a name="151123976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123976">(Dec 07 2018 at 16:36)</a>:</h4>
<p>I think the concern boats cited -- people worrying about FFI mismatches and defining/seeking a c_bool type -- is a real danger even if, as is currently the case, _Bool is a byte on every platform Rust is ever ported to</p>



<a name="151123994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151123994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151123994">(Dec 07 2018 at 16:36)</a>:</h4>
<p>it's not a <em>portability</em> danger, but a danger to code quality and people's time</p>



<a name="151124003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124003">(Dec 07 2018 at 16:36)</a>:</h4>
<p>i think so too</p>



<a name="151124016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124016">(Dec 07 2018 at 16:37)</a>:</h4>
<p>though clearly the decision made by the teams then is also a danger of people's time because it seems we are going to have this discussion every 2 years or so^^</p>



<a name="151124046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124046">(Dec 07 2018 at 16:37)</a>:</h4>
<p>but it's the time of the sort of nerd who willingly gets into this sort of debate, not the time of normal rust users</p>



<a name="151124100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124100">(Dec 07 2018 at 16:38)</a>:</h4>
<p>I got nerdsniped. I dont even care about portability. :P</p>



<a name="151124113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124113">(Dec 07 2018 at 16:38)</a>:</h4>
<p>boats also mentioned the opposite concern, that people would use <code>struct Bool(u8)</code> in Rust to make sure that in such platforms some <code>bool</code>s are indeed 1 byte wide</p>



<a name="151124120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124120">(Dec 07 2018 at 16:38)</a>:</h4>
<p>i got nerdsniped too</p>



<a name="151124264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124264">(Dec 07 2018 at 16:40)</a>:</h4>
<p>honestly I wish we would just have gone the <code>c_bool</code> way</p>



<a name="151124304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124304">(Dec 07 2018 at 16:41)</a>:</h4>
<p>I wish C wasn't such a vague standard</p>



<a name="151124306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124306">(Dec 07 2018 at 16:41)</a>:</h4>
<p>those are type aliases, not new types, so you can pass <code>bool</code> to it and call it a day</p>



<a name="151124403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124403">(Dec 07 2018 at 16:42)</a>:</h4>
<p>I <em>know</em> if it's a type alias some people are going to treat them as separate types anyway and develop a phobia to just using <code>bool</code> in FFI-adjacent Rust code</p>



<a name="151124436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124436">(Dec 07 2018 at 16:42)</a>:</h4>
<p>I just don't write FFI-adjacent code that often</p>



<a name="151124505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124505">(Dec 07 2018 at 16:43)</a>:</h4>
<p>I find the trade off of sane reliable bools everywhere with a bit of "unfounded" paranoia in C FFI code acceptable</p>



<a name="151124603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124603">(Dec 07 2018 at 16:44)</a>:</h4>
<p>I really don't care strongly enough about hypothetical weirdo platforms which effectively puts me in the camp of the status quo (which is bool == _Bool)</p>



<a name="151124606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124606">(Dec 07 2018 at 16:44)</a>:</h4>
<p>users doing C FFI have to know better anyways</p>



<a name="151124612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124612">(Dec 07 2018 at 16:44)</a>:</h4>
<p>I'll leave it at that</p>



<a name="151124652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124652">(Dec 07 2018 at 16:45)</a>:</h4>
<blockquote>
<p>I really don't care strongly enough about hypothetical weirdo platforms which effectively puts me in the camp of the status quo (which is bool == _Bool)</p>
</blockquote>
<p>I think you are in camp "require sizeof(_Bool) == 1 for FFI", which is different (it is stronger)</p>



<a name="151124728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124728">(Dec 07 2018 at 16:46)</a>:</h4>
<p>bool == _Bool is explicitly the standing team decision, I don't care enough about the subject to tease out corollaries from it (if this even is one)</p>



<a name="151124809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124809">(Dec 07 2018 at 16:47)</a>:</h4>
<p>if one never targets a platform where <code>sizeof(_Bool) != 1</code> then it doesn't really matter whether that is required or not, you can just assume it</p>



<a name="151124827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151124827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151124827">(Dec 07 2018 at 16:47)</a>:</h4>
<p>and write code accordingly</p>



<a name="151125086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151125086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151125086">(Dec 07 2018 at 16:50)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> it's not a corollary. I just interpreted your "dont care about weirdo platforms".</p>



<a name="151125852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151125852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151125852">(Dec 07 2018 at 17:01)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I haven't followed the whole discussion but I didn't say that I need to support any platform with CHAR_BITS != 8 nor _Bool not being equivalent to Rust's bool.</p>



<a name="151125939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151125939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151125939">(Dec 07 2018 at 17:02)</a>:</h4>
<p>IIRC, I did say that it seems possible to support platforms that have a different representation of <code>_Bool</code> by just not allowing <code>bool</code> in <code>#[repr(C)]</code> types and not allowing <code>bool</code> in <code>extern "C"</code> declarations when targetting those platforms.</p>



<a name="151125964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151125964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151125964">(Dec 07 2018 at 17:02)</a>:</h4>
<p>Whether that's a good idea or not, I don't know and I don't particularly care.</p>



<a name="151126095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151126095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151126095">(Dec 07 2018 at 17:04)</a>:</h4>
<p>Last year there was some effort to define a mechanism to say that certain platforms don't support certain things. For example, it is very useful to allow <code>impl From&lt;u32&gt; for usize</code> and <code>impl From&lt;usize&gt; for u64</code> and it would work fine 99% of the time, but if you want to support 16-bit platforms then you can't have <code>impl From&lt;u32&gt; for usize</code> on that platform.</p>



<a name="151126197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool%20%3D%3D%20_Bool/near/151126197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/bool.20.3D.3D.20_Bool.html#151126197">(Dec 07 2018 at 17:06)</a>:</h4>
<p>It seems like a more general problem and if there were a more general solution to this kind of subsetting then I think it would also solve disputes like this. But a more general subsetting mechanism seems to have made no progress.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>